from tqdm import tqdm


def main():
    print('extract lines')
    fp = open("train.txt", 'r', errors='ignore', encoding='utf-8')
    fp2 = open("train.txt", 'w', errors='ignore', encoding='utf-8')

    lines = fp.readlines()
    for line in tqdm(lines):
        newLine = ''
        sentences = line.split('\t')
        for i in range(len(sentences)):
            if i == 0:
                newLine += 'E'
            else:
                if '\n' not in sentences[i]:
                    newLine += '\nM ' + sentences[i] + '/'
                else:
                    newLine += '\nM ' + sentences[i].split('\n')[0] + '/\n'
            """
            if '\n' not in sentences[i]:
                newLine += sentences[i] + '/'
            else:
                newLine += sentences[i]
            """
        fp2.write(newLine)


if __name__ == '__main__':
    main()
